home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / doc / python-apt / text / apt / cache.txt next >
Encoding:
Text File  |  2009-03-30  |  3.7 KB  |  180 lines

  1.  
  2. ``apt.cache`` --- The Cache class
  3. *********************************
  4.  
  5.  
  6. The Cache class
  7. ===============
  8.  
  9. class apt.cache.Cache(progress=None, rootdir=None, memonly=False)
  10.  
  11.    Dictionary-like package cache.
  12.  
  13.    This class has all the packages that are available in it's
  14.    dictionary
  15.  
  16.    cache[pkgname]
  17.  
  18.       Return a ``Package()`` for the package with the name *pkgname*.
  19.  
  20.    additionalRequiredSpace
  21.  
  22.       Get the size of the additional required space on the fs.
  23.  
  24.    cachePostChange()
  25.  
  26.       called internally if the cache has changed, emit a signal then
  27.  
  28.    cachePreChange()
  29.  
  30.       called internally if the cache is about to change, emit a signal
  31.       then
  32.  
  33.    clear()
  34.  
  35.       Unmark all changes
  36.  
  37.    commit(fetchProgress=None, installProgress=None)
  38.  
  39.       Apply the marked changes to the cache
  40.  
  41.    connect(name, callback)
  42.  
  43.       connect to a signal, currently only used for
  44.       cache_{post,pre}_{changed,open}
  45.  
  46.    getChanges()
  47.  
  48.       Get the marked changes
  49.  
  50.    getProvidingPackages(virtual)
  51.  
  52.       Return a list of packages which provide the virtual package of
  53.       the specified name
  54.  
  55.    has_key(key)
  56.  
  57.    installArchives(pm, installProgress)
  58.  
  59.    isVirtualPackage(pkgname)
  60.  
  61.       Return whether the package is a virtual package.
  62.  
  63.    keys()
  64.  
  65.    open(progress)
  66.  
  67.       Open the package cache, after that it can be used like a
  68.       dictionary
  69.  
  70.    reqReinstallPkgs
  71.  
  72.       Return the packages not downloadable packages in reqreinst
  73.       state.
  74.  
  75.    requiredDownload
  76.  
  77.       Get the size of the packages that are required to download.
  78.  
  79.    update(fetchProgress=None)
  80.  
  81.       run the equivalent of apt-get update
  82.  
  83.    upgrade(distUpgrade=False)
  84.  
  85.       Upgrade the all package, DistUpgrade will also install new
  86.       dependencies
  87.  
  88.  
  89. Example
  90. -------
  91.  
  92. The following example shows how to load the cache, update it, and
  93. upgrade all the packages on the system:
  94.  
  95.    import apt
  96.    import apt.progress
  97.  
  98.    # First of all, open the cache
  99.    cache = apt.Cache()
  100.    # Now, lets update the package list
  101.    cache.update()
  102.    # We need to re-open the cache because it needs to read the package list
  103.    cache.open(None)
  104.    # Now we can do the same as 'apt-get upgrade' does
  105.    cache.upgrade()
  106.    # or we can play 'apt-get dist-upgrade'
  107.    cache.upgrade(True)
  108.    # Q: Why does nothing happen?
  109.    # A: You forgot to call commit()!
  110.    cache.commit(apt.progress.TextFetchProgress(),
  111.                 apt.progress.InstallProgress())
  112.  
  113.  
  114. Working with Filters
  115. ====================
  116.  
  117. class apt.cache.Filter
  118.  
  119.    Filter base class
  120.  
  121.    apply(pkg)
  122.  
  123.       Filter function, return True if the package matchs a filter
  124.       criteria and False otherwise
  125.  
  126. class apt.cache.MarkedChangesFilter
  127.  
  128.    Filter that returns all marked changes
  129.  
  130.    apply(pkg)
  131.  
  132. class apt.cache.FilteredCache(cache=None, progress=None)
  133.  
  134.    A package cache that is filtered.
  135.  
  136.    Can work on a existing cache or create a new one
  137.  
  138.    filterCachePostChange()
  139.  
  140.       Called internally if the cache changes, emit a signal then.
  141.  
  142.    has_key(key)
  143.  
  144.    keys()
  145.  
  146.    setFilter(filter)
  147.  
  148.       Set the current active filter.
  149.  
  150.  
  151. Example
  152. -------
  153.  
  154. This is an example for a filtered cache, which only allows access to
  155. the packages whose state has been changed, eg. packages marked for
  156. installation:
  157.  
  158.    >>> from apt.cache import FilteredCache, Cache, MarkedChangesFilter
  159.    >>> cache = apt.Cache()
  160.    >>> changed = apt.FilteredCache(cache)
  161.    >>> changed.setFilter(MarkedChangesFilter())
  162.    >>> print len(changed) == len(cache.GetChanges()) # Both need to have same length
  163.    True
  164.  
  165.  
  166. Exceptions
  167. ==========
  168.  
  169. exception apt.cache.FetchCancelledException
  170.  
  171.    Exception that is thrown when the user cancels a fetch operation.
  172.  
  173. exception apt.cache.FetchFailedException
  174.  
  175.    Exception that is thrown when fetching fails.
  176.  
  177. exception apt.cache.LockFailedException
  178.  
  179.    Exception that is thrown when locking fails.
  180.